/*
 * Create by erik on 18-9-17 下午1:58
 * Copyright (c) 2018. All rights reserved.
 *
 * Last Modified 18-9-17 下午1:58
 */

package com.feeyo.groundservice.fpush

import android.content.Context
import android.content.Intent

object PushBroadCast {

    /**
     *发送自定义的广播
     */
    fun sendBroadCast(
        context: Context,
        action: String,
        title: String?,
        content: String?,
        extraJsonString: String?
    ) {
        val intent = Intent(context.packageName + "." + action)
        intent.putExtra(Constant.EXTRA_TITLE, title)
        intent.putExtra(Constant.EXTRA_CONTENT, content)
        intent.putExtra(Constant.EXTRA_EXTRA, extraJsonString)
        intent.`package` = context.packageName

        context.sendBroadcast(intent)
    }


    /**
     *发送透传消息
     */
    fun sendMsgBroadCast(
        context: Context,
        title: String?,
        content: String?,
        extraJsonString: String?
    ) {
        val intent = Intent(context.packageName + "." + Constant.MSG_RECEIVE_ACTION)
        intent.putExtra(Constant.EXTRA_TITLE, title)
        intent.putExtra(Constant.EXTRA_CONTENT, content)
        intent.putExtra(Constant.EXTRA_EXTRA, extraJsonString)
        intent.`package` = context.packageName

        context.sendBroadcast(intent)
    }

    /**
     * 注册极光的设备型号
     */

    fun sendRegistration(context: Context, registration: String?, brand: String?) {
        val intent = Intent(context.packageName + "." + Constant.REGID_RECEIVE_ACTION)
        intent.putExtra(Constant.EXTRA_REGISTRATION, registration)
        intent.putExtra(Constant.EXTRA_BRAND, brand)
        intent.`package` = context.packageName
        context.sendBroadcast(intent)
    }

    /**
     * 点击通知
     * **/
    fun sendNotificationClick(context: Context, extra: String?) {
        val intent = Intent(context.packageName + "." + Constant.NOTIFICATION_CLICK)
        intent.putExtra(Constant.NOTIFICATION_CLICK, extra)
        intent.`package` = context.packageName
        context.sendBroadcast(intent)
    }

    /**
     * 通知到达设备
     * **/
    fun sendNotificationArrived(context: Context, extra: String?) {
        val intent = Intent(context.packageName + "." + Constant.NOTIFICATION_ARRIVED)
        intent.putExtra(Constant.NOTIFICATION_ARRIVED, extra)
        intent.`package` = context.packageName
        context.sendBroadcast(intent)
    }
}